package com.server.autoconfiguration;

import com.server.bean.Instance;
import com.server.controller.EurekaServerController;
import com.server.innotation.EnableEurekaMarkerServer;
import com.server.task.MyTask;
import com.server.task.TaskManager;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * Description:
 *
 * @author weiruibai.vendor
 * Date: 2023/1/28 15:47
 */
@ConditionalOnBean(EnableEurekaMarkerServer.Marker.class) // 开关
@Configuration
public class EurekaServerAutoConfiguration {


    @Bean
    public Instance getInstance() {
        return new Instance();
    }

    @Bean
    public MyTask MyTaskInstance(Instance instance) {
        return new MyTask(instance);
    }

    @Bean
    public TaskManager getTaskManager(MyTask task, Instance instance) {
        return new TaskManager(task, instance);
    }

    /**
     * 自定义的注册到自动配置中
     *
     * @return
     */
    @Bean
    public EurekaServerController getEurekaServerController() {
        return new EurekaServerController();
    }

    @Bean
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

}
